<?php

/**
 * This is the model class for table "{{r_programa}}".
 *
 * The followings are the available columns in table '{{r_programa}}':
 * @property integer $grid_programa_id
 * @property string $grid_programa_fecha
 * @property string $grid_programa_hora
 * @property string $grid_programa_minuto
 * @property string $grid_programa_descripcion
 * @property integer $grid_deporte_actividad_id
 * @property integer $grid_ubicacion_id
 * @property string $grid_nivel
 *
 * The followings are the available model relations:
 * @property DeporteActividad $gridDeporteActividad
 * @property RUbicacion $gridUbicacion
 */
class RPrograma extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return RPrograma the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{r_programa}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('grid_programa_fecha, grid_programa_descripcion, grid_deporte_actividad_id, grid_ubicacion_id, grid_nivel', 'required'),
			array('grid_deporte_actividad_id, grid_ubicacion_id', 'numerical', 'integerOnly'=>true),
			array('grid_programa_hora, grid_programa_minuto, grid_nivel', 'length', 'max'=>10),
			array('grid_programa_descripcion', 'length', 'max'=>200),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('grid_programa_id, grid_programa_fecha, grid_programa_hora, grid_programa_minuto, grid_programa_descripcion, grid_deporte_actividad_id, grid_ubicacion_id, grid_nivel', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'gridDeporteActividad' => array(self::BELONGS_TO, 'DeporteActividad', 'grid_deporte_actividad_id'),
			'gridUbicacion' => array(self::BELONGS_TO, 'RUbicacion', 'grid_ubicacion_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'grid_programa_id' => 'Programa ID',
			'grid_programa_fecha' => 'FECHA :',
			'grid_programa_hora' => 'HORA (FORMATO 24 HORAS) :',
			'grid_programa_minuto' => 'MINUTO',
			'grid_programa_descripcion' => 'DESCRIPCIÓN :',
			'grid_deporte_actividad_id' => 'DEPORTE :',
			'grid_ubicacion_id' => 'UBICACIÓN :',
			'grid_nivel' => 'NIVEL :',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('grid_programa_id',$this->grid_programa_id);
		$criteria->compare('grid_programa_fecha',$this->grid_programa_fecha,true);
		$criteria->compare('grid_programa_hora',$this->grid_programa_hora,true);
		$criteria->compare('grid_programa_minuto',$this->grid_programa_minuto,true);
		$criteria->compare('grid_programa_descripcion',$this->grid_programa_descripcion,true);
		$criteria->compare('grid_deporte_actividad_id',$this->grid_deporte_actividad_id);
		$criteria->compare('grid_ubicacion_id',$this->grid_ubicacion_id);
		$criteria->compare('grid_nivel',$this->grid_nivel,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}